//package com.woniuxy.commons.consumer;
//
//import cn.hutool.core.date.DateUnit;
//import cn.hutool.core.date.DateUtil;
//import com.woniuxy.elderlycare.util.RedisKeyUtil;
//import com.woniuxy.elderlycare.util.RedisUtil;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.Date;
//
//@Component
//@RabbitListener(queues = "user_register_queue")
//public class UserRegisterConsumer {
//    @Autowired
//    private RedisUtil redisUtil;
//    @RabbitHandler
//    public void handler(String phone) throws Exception {
//        //调用SMS工具类，发送验证码
////        String code = smsUtil.send(phone);
//        String code = "123456";
//        //redis保存该有时限的验证码
//        redisUtil.set(RedisKeyUtil.registerCodeKey(phone), code, 300);
//        redisUtil.set(RedisKeyUtil.registerCodeOnMinute(phone), code, 60);
//        if (redisUtil.hasKey(RedisKeyUtil.sendNumbers(phone))) {
//            redisUtil.incr(RedisKeyUtil.sendNumbers(phone));
//        } else {
//            //获取
//            long expire = (long) (DateUtil.endOfDay(new Date()).between(new Date(), DateUnit.MS)) / 1000;
//            redisUtil.set(RedisKeyUtil.sendNumbers(phone), "1", expire);
//        }
//    }
//
//}
